<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of QidianDecoratorComment
 *
 * @author Implement <hdjahs@qq.com>
 */
class QidianDecoratorComment {

    private $obj;
    private $url;

    public function __construct(Qidian $obj) {
        $this->obj = $obj;
        $this->url = "http://book.qidian.com/ajax/book/GetBookForum?bookId=%s&chanId=%s&pageSize=15";
        $this->init();
    }

    public function init() {
        $tool = Tool::getIns();
        $bookId = $tool->strCutByStr($this->obj->result, '<meta http-equiv="mobile-agent" content="format=wml; url=http://m.qidian.com/book/showbook.aspx?bookid=', '">');
        $chanId = $tool->strCutByStr($this->obj->result, 'chanId=', '&');

        $url = sprintf($this->url, $bookId, $chanId);
        $this->obj->comment = $tool->httpGet($url);
    }

}
